package com.qf.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    /**
     * 成功
     */
    public static final int SUCCESS = 10000;
    /**
     * 失败
     */
    public static final int ERROR = 10001;
    /**
     * 未登录
     */
    public static final int NO_LOGIN = 20001;
    /**
     * 没权限
     */
    public static final int NO_AUTH = 20002;


    /**
     * 标识结果的状态码
     */
    private int code;

    /**
     *  标识结果的描述信息
     */
    private String msg;

    /**
     * 向页面携带的数据
     */
    private Object data;

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(SUCCESS);
        result.setData(data);
        return  result;
    }
    public static Result success(Object data,String msg){
        Result result = new Result();
        result.setCode(SUCCESS);
        result.setData(data);
        result.setMsg(msg);
        return  result;
    }

    public static Result error(int code,String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return  result;
    }
}
